package com.lj.file.service.impl;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.x.file.storage.core.ProgressListener;

/**
 * @author luojing
 * @since 2025/7/4 18:18
 */
@AllArgsConstructor
@Slf4j
class ChunkProgressListener implements ProgressListener {

    private Long fileId;
    private int chunkNumber;
    private String operation;


    @Override
    public void start() {
        log.info("分片({}-{}): 开始{}", fileId, chunkNumber, operation);
    }

    @Override
    public void progress(long progressSize, Long allSize) {
        if (allSize != null) {
            log.info("分片({}-{}): 正在{} 总大小: {} 进度：{}%", fileId, chunkNumber, operation, allSize, (progressSize * 10000 / allSize * 0.01));
        }
    }

    @Override
    public void finish() {
        log.info("分片({}-{}): {}完成", fileId, chunkNumber, operation);
    }
}
